<% unless @key_results.empty? %>
    <div class="export-options">
      <%= link_to "PDF", current_url(:format => :pdf), :target => "_blank" %>
      <%= link_to "CSV", current_url(:format => :csv), :target => "_blank" %>
      <%= link_to "Excel", current_url(:format => :xls), :target => "_blank" %>
    </div>

    <table class="table sortable-table highchart" data-graph-container-before="1" data-graph-type="pie" data-graph-xaxis-rotation="-45">
      <thead>
      <tr>
        <th width="500">Task</th>
        <th data-graph-skip="1" width="200">OKR</th>
        <th data-graph-skip="1" width="300">Objective</th>
        <th data-graph-skip="1" width="300">Key result</th>
        <th data-graph-skip="1" width="100">Hours</th>
        <th data-graph-skip="1" class="hidden_class" width="100">Hours</th>
        <th class="hidden_class" width="100">Hours</th>
        <th data-graph-skip="1" width="100">Status</th>
      </tr>
      </thead>
      <tbody>
      <% @key_results.each do |k| %>
          <%# @tasks.each do |k, v| %>
          <% unless @tasks[k.id].nil? %>
              <% @tasks[k.id].each do |task| %>
                  <tr>
                    <td><%= task.name %></td>
                    <td><%= k.objective.okr.name %></td>
                    <td><%= k.objective.name %></td>
                    <td><%= k.name %></td>
                    <td class="hidden_class"><%= @work_logs[task.id].to_s.gsub(":","") %></td>
                    <td><%= @work_logs[task.id].nil? ? "0:00" : @work_logs[task.id] %></td>
                    <td class="hidden_class"><%= @work_logs[task.id].to_s.gsub(":",",") %></td>
                    <td><%= task.status == 'active' ? 'Pending' : task.status.capitalize  %></td>
                  </tr>
              <% end %>
          <% end %>
          <%# end %>
      <% end %>
      </tbody>

    </table>
    <script type="text/javascript">
        $(".sortable-table").tablesorter();
        if ($('.table tbody tr').length > 1) {
            $('table.highchart').highchartTable();
        }
    </script>
<% else %>
    <div class="alert-box secondary">
      No sufficient data yet.
    </div>
<% end %>